package com.wego.aop.service;

import java.util.Arrays;
import java.util.List;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class LoggingAspect {
	
	@Before("execution(public void com.wego.aop.service.PersonService.execute(..))")
	public void beforeMethod(JoinPoint point){
		System.out.println("method begins");
	}
	
	@After("execution(* com.wego.aop.service.PersonService.*(..))")
	public void afterMethod(JoinPoint point){
		String methodName = point.getSignature().getName();
		List<Object> args = Arrays.asList(point.getArgs());
		System.out.println("method: ["+methodName+"] ends with "+args);
	}

}
